<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1" import="custom.*, java.util.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<%! // return the index of the majors vector with a given major name
	int getMajorId(Vector<String> majors, String name) {
		for(int i=0; i < majors.size(); ++i ) {
			if(majors.get(i).equals( name) ) {
				return i;
			}
		}
		return -1;
	} 
%>
<%	// set session attribute for various degree information
	String major = request.getParameter("major");
	String majorSpecify = request.getParameter("majorSpecify");
	String month = request.getParameter("month");
	String year = request.getParameter("year");
	String gpa = request.getParameter("gpa");
	String type = request.getParameter("type");
	Vector<LinkedHashMap<String, Object>> degrees = (Vector<LinkedHashMap<String, Object>>)session.getAttribute("degrees");
	LinkedHashMap<String, Object> degree = degrees.get(degrees.size()-1);
	Vector majors = support.getMajors();

	int majorId = 0;
	// add the major name to the major vector if it is entered by the applicant
	if(majorSpecify != ""  ) {
        degree.put("majorName", majorSpecify);
    }
    else {
        degree.put("majorId", Integer.parseInt(major));
        for(int i = 0; i < majors.size(); i++) {
            Vector tmp = (Vector)majors.get(i);
            if((Integer)tmp.get(0) == Integer.parseInt(major)) {
                degree.put("majorName", tmp.get(1));
                break;
            }
        }
    }

	// save the degree information
	degree.put("month", month);
	degree.put("year", year);
	degree.put("gpa", gpa);
	degree.put("type", type);
	session.setAttribute("degrees", degrees);
    
%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>More Degrees</title>
</head>
<body>
<form method="GET" action="degreeLocation.jsp">
<input type="submit" value="Submit next degree"/>
</form> <p>
<form method="GET" action="specialization.jsp">
<input type="submit" value="Done"/>
</form>
</body>
</html>
